package pers.qianyu.month_202012.date_20201214;

/**
 * 剑指 Offer 14- I. 剪绳子
 * https://leetcode-cn.com/problems/jian-sheng-zi-lcof/
 *
 * @author mizzle rain
 * @date 2020-12-14 11:06
 */
public class CuttingRope {
    public int cuttingRope(int n) {
        if (n == 2) {
            return 1;
        }
        if (n == 3) {
            return 2;
        }
        int a = n % 3, b = n / 3;
        int res = (int) Math.pow(3, b);
        if (a == 1) {
            res = res / 3 * 4;
        } else if (a == 2) {
            res = res * 2;
        }
        return res;
    }
}
